The following patch fixes a bug where xenconsoled will can SEGV
authorkaf24@localhost.localdomain <kaf24@localhost.localdomain>
Mon, 28 Aug 2006 11:50:55 +0000 (12:50 +0100)
committerkaf24@localhost.localdomain <kaf24@localhost.localdomain>
Mon, 28 Aug 2006 11:50:55 +0000 (12:50 +0100)
because it uses FD_ISSET(-1,xxx).  Since the code is written that any
ring/tty handler can set d->tty_fd to -1 it has to be checked
_every_time_.

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
tools/console/daemon/io.c

index 5c0eaa0d9d0cae7d19f42cfa339b1d3b1f6a2401..93f96b101d08a475371d4800bd5c7c09b73c3319 100644 (file)
@@ -584,16 +584,14 @@ void handle_io(void)
                            FD_ISSET(xc_evtchn_fd(d->xce_handle), &readfds))
                                handle_ring_read(d);
 
-                       if (d->tty_fd != -1) {
-                               if (FD_ISSET(d->tty_fd, &readfds))
-                                       handle_tty_read(d);
+                       if (d->tty_fd != -1 && FD_ISSET(d->tty_fd, &readfds))
+                               handle_tty_read(d);
 
-                               if (FD_ISSET(d->tty_fd, &writefds))
-                                       handle_tty_write(d);
+                       if (d->tty_fd != -1 && FD_ISSET(d->tty_fd, &writefds))
+                               handle_tty_write(d);
 
-                               if (d->is_dead)
-                                       cleanup_domain(d);
-                       }
+                       if (d->is_dead)
+                               cleanup_domain(d);
                }
        } while (ret > -1);
 }